/*
 * @Author: your name
 * @Date: 2021-10-21 20:49:25
 * @LastEditTime: 2021-10-22 21:19:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\模板问题\P1020 导弹拦截\3main.cpp
 */

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

//导弹高度
int h[100010];
//f[i] 最长下降子序列
int f[100010];
int lenf = 0;
//g[j] 最长上升子序列
int g[100010];
int leng = 0;

//找寻findnum的位置
int binarySearch(int a[],int len,int findnum);
int binarySearch2(int a[],int len,int findnum);

//打印一个数组
void print(int a[],int len);

int main(){
    int n = 0;
    while(cin >> h[++n]); n--;
    
    //将f[0] 赋值为无穷大
    f[0] = 59999;
    for(int i=1; i<=n; i++){
        //最长上升子序列
        if(g[leng] < h[i]){
            //添加h[i] 进入g序列
            g[++leng] = h[i];
        }else{
            //如果将h[i]添加进序列 且leng不会减小即可
            int index = binarySearch(g,leng,h[i]);
            g[index] = h[i];
        }

        //最长下降子序列
        if(f[lenf] >= h[i]){
            f[++lenf] = h[i];
        }else{
            //有问题 新值大于末尾值 找合适的位置
            int index = binarySearch2(f,lenf,h[i]);
            f[index] = h[i];
        }
        // print(f,lenf);
    }
    // cout << "------------------" << endl;
    cout << lenf << endl;
    cout << leng << endl;
   return 0;
}

int binarySearch(int a[],int len,int findnum)
{
    int l = 1,r = len;
    int m;
    while(l < r){
        m = (l+r)/2; //左开
        if(findnum > a[m]){
            l = m+1;
        }else{
            r = m;
        }
    }
    return l;
}

int binarySearch2(int a[],int len,int findnum)
{
    int l = 1,r = len;
    int m;
    while(l < r){
        m = (l+r)/2; //左开
        if(findnum < a[m]){
            l = m+1;
        }else{
            r = m;
        }
    }
    return l;
}


void print(int a[],int len)
{
    for(int i=1; i<=len; i++){
        cout << a[i] << " ";
    }
    cout << endl;
}